package com.cw.base.jeeyc.biz.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;

import com.cw.base.jeeyc.biz.intf.IExceptionCallbackBiz;
import com.cw.exception.callback.api.ExceptionCallbackApi;
import com.cw.exception.callback.dto.ExceptionCallbackReqDto;
import com.cw.exception.callback.enums.EnumExceptionCallbackTradeType;
import com.cw.lang.common.utils.IdGenerator;

@Service
public class ExceptionCallbackBizImpl implements IExceptionCallbackBiz {
    @Autowired
    private ExceptionCallbackApi exceptionCallbackApi;
    @Override
    public boolean testCallback() {
        //dubbo
        ExceptionCallbackReqDto dubboReqDto = new ExceptionCallbackReqDto();
        dubboReqDto.setAnswer("hrkj-ruoyi-center");
        dubboReqDto.setAsk("jeeyc");
        dubboReqDto.setApplicationName("hrkj-ruoyi-center");
        dubboReqDto.setCallbackTime(new Date());
        dubboReqDto.setExceptionId(IdGenerator.nextId());
        dubboReqDto.setInterfaceName("com.ruoyi.yz.facade.intf.IYzVideoQuery");
        dubboReqDto.setInterfaceVersion("1.0.0");
        dubboReqDto.setInterfaceMethod("selectPage");
        dubboReqDto.setInterfaceParamNames("com.ruoyi.yz.facade.dto.request.YzVideoReqDto");
        dubboReqDto.setParams("{\"id\":1111,\"pageNum\":1,\"pageSize\":10}");
        dubboReqDto.setSerialNo(IdGenerator.nextStrId());
        dubboReqDto.setTradeType(EnumExceptionCallbackTradeType.DUBBO);
        exceptionCallbackApi.dubboExceptionCallback(dubboReqDto);
        //cloud http
        ExceptionCallbackReqDto cloudReqDto = new ExceptionCallbackReqDto();
        cloudReqDto.setAnswer("hrkj-ruoyi-center");
        cloudReqDto.setAsk("jeeyc");
        cloudReqDto.setApplicationName("hrkj-ruoyi-center");
        cloudReqDto.setCallbackTime(new Date());
        cloudReqDto.setExceptionId(IdGenerator.nextId());
        cloudReqDto.setHttpMethod(HttpMethod.POST.toString());
        cloudReqDto.setParams("{\"id\":1111,\"pageNum\":1,\"pageSize\":10}");
        //cloud
        cloudReqDto.setInterfacePath("/yz/v1/yzVideoQuery/selectPage");
        cloudReqDto.setTradeType(EnumExceptionCallbackTradeType.CLOUD);
        //http
        //cloudReqDto.setInterfacePath("http://127.0.0.1:8200/yz/v1/yzVideoQuery/selectPage");
        //cloudReqDto.setTradeType(EnumExceptionCallbackTradeType.HTTP);
        exceptionCallbackApi.cloudExceptionCallback(cloudReqDto);
        return false;
    }
}
